package com.allinpokers.vest.allinvest.controller;

import com.allinpokers.vest.allinvest.model.request.PageReq;
import com.allinpokers.vest.allinvest.model.request.vest.IosVestInfoAdCloseReq;
import com.allinpokers.vest.allinvest.model.request.vest.IosVestInfoAddReq;
import com.allinpokers.vest.allinvest.model.request.vest.IosVestInfoDelReq;
import com.allinpokers.vest.allinvest.model.request.vest.IosVestInfoUpdateReq;
import com.allinpokers.vest.allinvest.model.respon.CommonRespon;
import com.allinpokers.vest.allinvest.model.respon.IosVestInfoRespon;
import com.allinpokers.vest.allinvest.model.respon.PageBean;
import com.allinpokers.vest.allinvest.service.vest.IVestService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Api(value = "马甲", tags = "马甲控制")
@RestController
@RequestMapping("/v")
public class VestController {

    @Resource
    private IVestService iVestService;

    @ApiOperation(value = "下载次数")
    @GetMapping("/d/{item}")
    public CommonRespon downTime(@PathVariable(value = "item") String channelId) {
        return iVestService.saveDownTime(channelId);
    }

    @ApiOperation(value = "成功次数")
    @GetMapping("/s/{item}")
    public CommonRespon successTime(@PathVariable(value = "item") String channelId) {
        return iVestService.saveSuccessTime(channelId);
    }

    @ApiOperation(value = "开关")
    @GetMapping("/g/{item}")
    public String getOpen(@PathVariable(value = "item") String channelId) {
        return iVestService.getOpen(channelId);
    }


    @ApiOperation(value = "推广渠道列表")
    @PostMapping(value = "/list")
    public CommonRespon<PageBean<IosVestInfoRespon>> list(@RequestBody PageReq req) {
        return iVestService.iosVestList(req);
    }

    @ApiOperation(value = "添加")
    @PostMapping(value = "/add")
    public CommonRespon add(@RequestBody IosVestInfoAddReq req) {
        return iVestService.addIosVestInfo(req);
    }

    @ApiOperation(value = "编辑")
    @PostMapping(value = "/update")
    public CommonRespon update(@RequestBody IosVestInfoUpdateReq req) {
        return iVestService.updateIosVestInfo(req);
    }

    @ApiOperation(value = "落地页的开关")
    @PostMapping(value = "/close")
    public CommonRespon adClose(@RequestBody IosVestInfoAdCloseReq req) {
        return iVestService.closeOp(req);
    }

    @ApiOperation(value = "删除")
    @PostMapping(value = "/del")
    public CommonRespon del(@RequestBody IosVestInfoDelReq req) {
        return iVestService.del(req);
    }

}
